#ifndef PAGEBUILDER_H
#define	PAGEBUILDER_H

#include <string>
#include <ostream>
#include <fstream>
#include <exception>

class InputException: public std::exception
{
  virtual const char* what() const throw()
  {
    return "Can't read file\n";
  }
};

struct Page
{
    std::string text_;
    int number_;
    
    Page(int number, std::string text) :number_(number), text_(text)
    {
    }
    
    bool operator ==(const Page& page) const
    {
        return this->number_ == page.number_ && this->text_ == page.text_;
    }
};

std::ostream& operator<< (std::ostream& out, const Page& page);

class PageBuilder
{
public:
    PageBuilder();
    ~PageBuilder();
    void open(const char* path);
    void close();
    Page nextPage();
    bool hasNext();
    
private:
    bool isEndOfPage(std::string& line);
    
    std::ifstream input_;
    int pageCount_;
};

#endif	/* PAGEBUILDER_H */

